package model;

import model.impl.Passenger;
import DTO.ScheduleDTO;
import DTO.TicketDTO;

/**
 * This is an interface that provides a complete business transactions with 
 * an entity of Ticket
 */
public interface Ticket {

	/**
	 * This method checks if there an available a ticket in DB which has the same 
	 * DTO implementation of schedule as the given DTO of schedule. If such 
	 * ticket is possible to be created: there are free places on schedule, this
	 * passenger doesn't have ticket for this schedule, and departure time is 
	 * later than 10 minutes after current moment, then it creates suck ticket 
	 * and adds it to the DB.
	 * 
	 * @param scheduleDTO - schedule where it's required to buy ticket
	 * @param passenger	  - passenger which wants to buy ticket
	 * @return			  - DTO of created ticket or null if some of conditions
	 * 						failed.
	 */
	public TicketDTO buyTicket(ScheduleDTO scheduleDTO, Passenger passenger);
	
	/**
	 * This method checks if there is a ticket in DB which has the same 
	 * DTO implementation as the given DTO. If it is found in DB, method 
	 * removes it.
	 * 
	 * @param ticketDTO - DTO of train which is required to be sold.
	 * @return			- true if the ticket was sold or false in any other
	 * 					  cases.
	 */
	public boolean sellTicket(TicketDTO ticketDTO);
	
	/**
	 * This method checks if there is ticket in DB which has the same ID as 
	 * the given DTO. If such ticket is found , then it looks for schedule
	 * with which this ticket is associated, if such schedule is found method
	 * creates a DTO from it.
	 * 
	 * @param ticketDTO	- DTO of ticket for which it's required to find schedule
	 * @return			- DTO of created schedule or null if the search failed.
	 */
	public ScheduleDTO viewTickInfo(TicketDTO ticketDTO);
}
